#include <iostream>

using namespace std;
//前向引用声明
class Card;

class People
{
public:
	People(string _name)
	{
		name=_name;
	}
	void getCardMoney(Card &card);

private:
	string name;
};



class Card
{
public:
	Card(float _moneynum)
	{
		moneynum=_moneynum;
	}
	//声明People类的成员函数作为我自己的友元
	friend void People::getCardMoney(Card &card);
private:
	float moneynum;
};

//在类的外面实现People的成员函数
void People::getCardMoney(Card &card)
{
	cout<<"我访问了另外一个类的私有成员  "<<card.moneynum;
	//修改另外一个类的私有成员
	card.moneynum=0.0;
}



int main()
{
	//定义卡的对象
	Card card(8888888);
	
	//定义人的对象
	People p("马云");
	p.getCardMoney(card);

}